<template>
	<view class="pages">
		<view class="qrcode">
			<image :src="qrcodeUrl" mode=""></image>
			<view class="qrcode-a">{{details.qrcode}}</view>
			<view class="qrcode-b">购买时间：{{details.created_at}}</view>
			<view class="qrcode-c">{{details.status == 0?'未使用':'已使用'}}</view>
		</view>
	</view>
</template>

<script>
	import { HTTP_REQUEST_URL } from '@/config/app.js';
	import {
		qrcodedetail
	} from '@/api/user.js';
	export default {
		data() {
			return {
				details: {},
				qrcodeUrl: ''
			}
		},
		onLoad(options) {
			this.qrcode(options.id)
		},
		methods: {
			qrcode(id) {
				let self = this;
				qrcodedetail(id).then(res => {
					console.log('请求成功',res);
					self.details = res.data;
					self.qrcodeUrl = `http://qr.kegood.com?url=${HTTP_REQUEST_URL}/pages/users/applyChief/applyChief?qrcode=${res.data.qrcode}`;
				}).catch(err => {
					console.log('请求失败', err);
				})
			}
		}
	}
</script>

<style lang="less">
	.pages {
		min-height: 100vh;
		background-color: #f1f1f1;

		.qrcode {
			width: 632rpx;
			height: 850rpx;
			background: #FFFFFF;
			margin: 90rpx auto 0;
			padding-top: 108rpx;
			overflow: hidden;

			image {
				display: block;
				width: 382rpx;
				height: 382rpx;
				margin: 0 auto;
			}

			.qrcode-a {
				width: 382rpx;
				font-size: 34rpx;
				color: #969696;
				line-height: 1;
				text-align: center;
				padding-top: 24rpx;
				margin: 0 auto;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.qrcode-b {
				font-size: 24rpx;
				color: #5A5A5A;
				line-height: 1;
				text-align: center;
				padding: 60rpx 0 48rpx;
			}

			.qrcode-c {
				font-size: 38rpx;
				color: #5A5A5A;
				line-height: 180rpx;
				text-align: center;
				font-weight: 600;
				border-top: 2rpx dashed #f3f3f3;
				position: relative;
			}

			.qrcode-c::before {
				content: '';
				width: 24rpx;
				height: 24rpx;
				border-radius: 24rpx;
				background-color: #f1f1f1;
				position: absolute;
				top: -12rpx;
				left: -12rpx;
				z-index: 2;
			}

			.qrcode-c::after {
				content: '';
				width: 24rpx;
				height: 24rpx;
				border-radius: 24rpx;
				background-color: #f1f1f1;
				position: absolute;
				top: -12rpx;
				right: -12rpx;
				z-index: 2;
			}
		}
	}
</style>
